package handle;

import common.Constants.ServiceConstant;
import common.Result;
import dataBean.UserDo;
import dataBean.UserInfoDo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import service.UserService;
import service.VerifyService;

import java.io.Serializable;

/**
 * Created by lxl on 2015/11/3.
 */
@Controller
@RequestMapping("ssms/add")
public class AddUserHandle {

    @Autowired
    private UserService userService ;

    @Autowired
    private VerifyService verifyService ;

    @RequestMapping( value = ("/user"),method = RequestMethod.POST)
    public @ResponseBody
    Result process( @RequestBody UserInfoDo userInfoDo , @RequestHeader String token ){

        Result result = verifyService.verify(token,ServiceConstant.ADMIN_LEVEL) ;

        if( result.isSucces() ){

            result = userService.addUser(userInfoDo) ;

        }

        return  result ;
    }

}
